from app.services.business.gaolu_diagnose.ind.abstract_ind import AbstractInd


class CG_LT_GL_GL04_Tie_V(AbstractInd):

    def get_name(self):
        return "CG_LT_GL_GL04_Tie_V"

    def get_data_source(self):
        return "mysql"

    def get_sql(self, params):
        sql_Tie_V = """      
        select round(avg(jyh.jyjg),3) as CG_LT_GL_GL04_Tie_V 
        from 
        (select jyh.*,jyt.ph, tqpd.tjsj
        from syn_zl_zl_jyh as jyh ,syn_zl_zl_jyt as jyt ,syn_zl_zl_tqpd as tqpd
        where  jyh.jcxmbm='01048' and jyh.zfbz='0'  and tqpd.ztbz ='1'
        and jyt.wlbm = '60110101' 
        and SUBSTRING(jyt.ph, 3, 1) = '4' 
        and  jyt.jytid = jyh.jytid 
        and  jyt.ph = tqpd.ph
        and jyh.jyjg NOT LIKE '%#%' 
        and tqpd.tjsj > DATE_SUB(CURTIME(), INTERVAL 0.60 hour)  ) as jyh        

                """.format(**params)
        return sql_Tie_V
